#define  _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

class Implementor
{
public:
	virtual ~Implementor() {}
	virtual void ImplementedOperation() = 0;
};

class ConcreteImplementor : public Implementor
{
public:
	virtual void ImplementedOperation()
	{
		cout << "ConcreteImplementor " << endl;
	}
};

class Abstraction
{
public:
	Abstraction(Implementor* impl) : impl_(impl)
	{

	}
	virtual ~Abstraction()
	{
		delete impl_;
	}
	void operation()
	{
		cout << "operation ";
		impl_->ImplementedOperation();
	}
protected:
	Implementor* impl_;
};

class RefinedAbstraction : public Abstraction
{
public:
	RefinedAbstraction(Implementor* impl):Abstraction(impl){}
	void newAddedOperation()
	{
		cout << "newAddedOperation ";
		impl_->ImplementedOperation();
	}
};

//int main()
//{
//	Abstraction* ab = new Abstraction(new ConcreteImplementor());
//	ab->operation();
//
//	RefinedAbstraction* rab = new RefinedAbstraction(new ConcreteImplementor());
//	rab->newAddedOperation();
//	return 0;
//}
